<template>
  <div class="container">
    <div>
      <div class="ifw" v-if="stujob">
        <iframe :src="src" frameborder="0"></iframe>
      </div>
      <h1 v-else class="title">少年，你还没有获得奖励！</h1>
    </div>
  </div>
</template>

<script>
import axios from "axios";

export default {
  data() {
    return {
      rewardf: false,
      games: [
        "js-chrome-dino-runner-master",
        "feiyu22-jsnes-master",
        "TheAviator",
        "the-frantic-run-of-the-valorous-rabbit",
        "bike",
        "2048",
        "40963",
        "allalive",
        "attackonball",
        "ballgame",
        "bike",
        "blindmoon",
        "blockdown",
        "bottle3",
        "breaklovers",
        "breakout3",
        "candy",
        "candytbc",
        "catapult",
        "charge",
        "circlepath",
        "collectstar",
        "crazybird",
        "dinosaur",
        "donottapwhitetile",
        "doudizhu",
        "downfloor",
        "dragandmatch",
        "eatball",
        "eliminate",
        "fctank",
        "fifty",
        "findpath",
        "flappybird",
        "flappybird3",
        "fruit",
        "fruitwar",
        "fubag",
        "getcockscomb",
        "getcoins3",
        "getogether",
        "getthestarforyou",
        "hearthstone",
        "hitball",
        "hitgraywolf3",
        "jump",
        "jumpone",
        "justshoot",
        "kite",
        "knifehit3",
        "kupao",
        "learn",
        "learn3",
        "legendofwolf",
        "feiyu22-jsnes-master",
        "magicplain",
        "manna",
        "marathon",
        "maze",
        "memory",
        "minorminer",
        "nail",
        "p2ball",
        "pacman",
        "partials",
        "petparty",
        "pixelstar",
        "plane",
        "prize",
        "puzzle",
        "quickrush3",
        "quitsmoke",
        "randomdungeon",
        "rhythm",
        "rocket",
        "rpgdemo",
        "run",
        "runrobot",
        "russianblock",
        "scaldfish",
        "seckill",
        "services",
        "shenjingmao",
        "shoot",
        "simplechess",
        "skeletonguard",
        "snap",
        "stardog",
        "starship",
        "susliks",
        "swordart",
        "tacit",
        "tank",
        "timberpig",
        "tools",
        "twowar",
        "unforgetday",
        "weiduan",
        "wipeglass",
      ],
      hills: {},
      gamec: "",
      stujob: false,
    };
  },
  created() {
    let arr = this.games;
    this.gamec = arr[Math.floor(Math.random() * arr.length)];
    axios.get("/api/gameauth").then((res) => {
      this.stujob = res.data;
      // if (this.stujob) {
      //   // let arr = this.games;
      //   // let gamec = arr[Math.floor(Math.random() * arr.length)];
      //   // this.$router.replace("/api/material/games/" + gamec + "/index.html");
      // }
    });
  },
  computed: {
    src() {
      return (
        "http://192.168.1.254:8080/api/material/games/" +
        this.gamec +
        "/index.html"
      );
    },
  },
};
</script>

<style>
.ifw {
  width: 100%;
  height: 70vh;
}
iframe {
  width: 100%;
  height: 100%;
}
</style>
